import { parseEther } from "viem";
import { useWriteContract } from "wagmi";

function MintNFT() {
  const { writeContract } = useWriteContract();

  const handleMint = () => {
    writeContract(
      {
        address: "0xd9145CCE52D386f254917e481eB44e9943F39138",
        abi: [
          {
            type: "function",
            name: "mint",
            stateMutability: "payable",
            inputs: [{ name: "quantity", type: "uint256" }],
            outputs: [],
          },
        ],
        functionName: "mint",
        args: [BigInt(1)], // 铸造 1 个 NFT
        value: parseEther("0.01"), // 支付 ETH
      },
      {
        onSuccess: () => console.log("铸造成功"),
        onError: (err) => console.error(err.message),
      }
    );
  };

  return <button onClick={handleMint}>铸造 NFT</button>;
}
export default MintNFT;
